<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
    <title>Coverage Report :: Board</title>
    <style type="text/css">
        @import "../../.css/coverage.css";
    </style>
</head>

<body>
<div class="header"></div>

<div class="content">
    <div class="breadCrumbs">
        [ <a href="../../index.html">all classes</a> ]
        [ <a href="../index.html">nl.tudelft.jpacman.board</a> ]
    </div>

    <h1>Coverage Summary for Class: Board (nl.tudelft.jpacman.board)</h1>

    <table class="coverageStats">
        <tr>
            <th class="name">Class</th>
            <th class="coverageStat
">
                Class, %
            </th>
            <th class="coverageStat
">
                Method, %
            </th>
            <th class="coverageStat
">
                Line, %
            </th>
        </tr>
        <tr>
            <td class="name">Board</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 1)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 7)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 18)
  </span>
            </td>
        </tr>

    </table>

    <br/>
    <br/>


    <div class="sourceCode"><i>1</i>&nbsp;package nl.tudelft.jpacman.board;
        <i>2</i>&nbsp;
        <i>3</i>&nbsp;
        <i>4</i>&nbsp;/**
        <i>5</i>&nbsp; * A top-down view of a matrix of {@link Square}s.
        <i>6</i>&nbsp; *
        <i>7</i>&nbsp; * @author Jeroen Roosen
        <i>8</i>&nbsp; */
        <b class="nc"><i>9</i>&nbsp;public class Board {</b>
        <i>10</i>&nbsp;
        <i>11</i>&nbsp; /**
        <i>12</i>&nbsp; * The grid of squares with board[x][y] being the square at column x, row y.
        <i>13</i>&nbsp; */
        <i>14</i>&nbsp; private final Square[][] board;
        <i>15</i>&nbsp;
        <i>16</i>&nbsp; /**
        <i>17</i>&nbsp; * Creates a new board.
        <i>18</i>&nbsp; *
        <i>19</i>&nbsp; * @param grid
        <i>20</i>&nbsp; * The grid of squares with grid[x][y] being the square at column
        <i>21</i>&nbsp; * x, row y.
        <i>22</i>&nbsp; */
        <i>23</i>&nbsp; @SuppressWarnings(&quot;PMD.ArrayIsStoredDirectly&quot;)
        <b class="nc"><i>24</i>&nbsp; Board(Square[][] grid) {</b>
        <b class="nc"><i>25</i>&nbsp; assert grid != null;</b>
        <b class="nc"><i>26</i>&nbsp; this.board = grid;</b>
        <b class="nc"><i>27</i>&nbsp; assert invariant() : &quot;Initial grid cannot contain null squares&quot;;</b>
        <b class="nc"><i>28</i>&nbsp; }</b>
        <i>29</i>&nbsp;
        <i>30</i>&nbsp; /**
        <i>31</i>&nbsp; * Whatever happens, the squares on the board can&#39;t be null.
        <i>32</i>&nbsp; * @return false if any square on the board is null.
        <i>33</i>&nbsp; */
        <i>34</i>&nbsp; protected final boolean invariant() {
        <b class="nc"><i>35</i>&nbsp; for (Square[] row : board) {</b>
        <b class="nc"><i>36</i>&nbsp; for (Square square : row) {</b>
        <b class="nc"><i>37</i>&nbsp; if (square == null) {</b>
        <b class="nc"><i>38</i>&nbsp; return false;</b>
        <i>39</i>&nbsp; }
        <i>40</i>&nbsp; }
        <i>41</i>&nbsp; }
        <b class="nc"><i>42</i>&nbsp; return true;</b>
        <i>43</i>&nbsp; }
        <i>44</i>&nbsp;
        <i>45</i>&nbsp; /**
        <i>46</i>&nbsp; * Returns the number of columns.
        <i>47</i>&nbsp; *
        <i>48</i>&nbsp; * @return The width of this board.
        <i>49</i>&nbsp; */
        <i>50</i>&nbsp; public int getWidth() {
        <b class="nc"><i>51</i>&nbsp; return board.length;</b>
        <i>52</i>&nbsp; }
        <i>53</i>&nbsp;
        <i>54</i>&nbsp; /**
        <i>55</i>&nbsp; * Returns the number of rows.
        <i>56</i>&nbsp; *
        <i>57</i>&nbsp; * @return The height of this board.
        <i>58</i>&nbsp; */
        <i>59</i>&nbsp; public int getHeight() {
        <b class="nc"><i>60</i>&nbsp; return board[0].length;</b>
        <i>61</i>&nbsp; }
        <i>62</i>&nbsp;
        <i>63</i>&nbsp; /**
        <i>64</i>&nbsp; * Returns the square at the given &lt;code&gt;x,y&lt;/code&gt; position.
        <i>65</i>&nbsp; *
        <i>66</i>&nbsp; * Precondition: The &lt;code&gt;(x, y)&lt;/code&gt; coordinates are within the
        <i>67</i>&nbsp; * width and height of the board.
        <i>68</i>&nbsp; *
        <i>69</i>&nbsp; * @param x
        <i>70</i>&nbsp; * The &lt;code&gt;x&lt;/code&gt; position (column) of the requested square.
        <i>71</i>&nbsp; * @param y
        <i>72</i>&nbsp; * The &lt;code&gt;y&lt;/code&gt; position (row) of the requested square.
        <i>73</i>&nbsp; * @return The square at the given &lt;code&gt;x,y&lt;/code&gt; position (never null).
        <i>74</i>&nbsp; */
        <i>75</i>&nbsp; public Square squareAt(int x, int y) {
        <b class="nc"><i>76</i>&nbsp; assert withinBorders(x, y);</b>
        <b class="nc"><i>77</i>&nbsp; Square result = board[x][y];</b>
        <b class="nc"><i>78</i>&nbsp; assert result != null : &quot;Follows from invariant.&quot;;</b>
        <b class="nc"><i>79</i>&nbsp; return result;</b>
        <i>80</i>&nbsp; }
        <i>81</i>&nbsp;
        <i>82</i>&nbsp; /**
        <i>83</i>&nbsp; * Determines whether the given &lt;code&gt;x,y&lt;/code&gt; position is on this board.
        <i>84</i>&nbsp; *
        <i>85</i>&nbsp; * @param x
        <i>86</i>&nbsp; * The &lt;code&gt;x&lt;/code&gt; position (row) to test.
        <i>87</i>&nbsp; * @param y
        <i>88</i>&nbsp; * The &lt;code&gt;y&lt;/code&gt; position (column) to test.
        <i>89</i>&nbsp; * @return &lt;code&gt;true&lt;/code&gt; iff the position is on this board.
        <i>90</i>&nbsp; */
        <i>91</i>&nbsp; public boolean withinBorders(int x, int y) {
        <b class="nc"><i>92</i>&nbsp; return x &gt;= 0 &amp;&amp; x &lt; getWidth() &amp;&amp; y &gt;= 0 &amp;&amp; y
            &lt; getHeight();</b>
        <i>93</i>&nbsp; }
        <i>94</i>&nbsp;}
    </div>
</div>

<div class="footer">

    <div style="float:right;">generated on 2023-04-25 16:45</div>
</div>
</body>
</html>
